package org.darkforest.model;

import org.apache.commons.lang3.StringUtils;
import org.darkforest.common.util.DateUtil;
import org.darkforest.common.util.Page;

public class HealthCycle extends Page<HealthCycle> {

    private Integer cycleId;
    private String cycleName;
    private String cycleYear;
    private Integer startDate;
    private Integer endDate;
    private String cycleState;

    // 显示字段（类型转化）
    private String startDateStr;
    private String endDateStr;

    // 移动端使用（服务端的系统时间）
    private Integer serverDate;

    public Integer getCycleId() {
        return cycleId;
    }
    public void setCycleId(Integer cycleId) {
        this.cycleId = cycleId;
    }

    public String getCycleName() {
        return cycleName;
    }
    public void setCycleName(String cycleName) {
        this.cycleName = cycleName == null ? null : cycleName.trim();
    }

    public String getCycleYear() {
        return cycleYear;
    }
    public void setCycleYear(String cycleYear) {
        this.cycleYear = cycleYear == null ? null : cycleYear.trim();
    }

    public Integer getStartDate() {
        // 从页面上取值时
        if (this.startDate == null && StringUtils.isNotEmpty(this.startDateStr)) {
            return DateUtil.toUnixTimeStampByDate(this.startDateStr);
        }

        return startDate;
    }
    public void setStartDate(Integer startDate) {
        this.startDate = startDate;
    }

    public Integer getEndDate() {
        // 从页面上取值时
        if (this.endDate == null && StringUtils.isNotEmpty(this.endDateStr)) {
            return DateUtil.toUnixTimeStampByDate(this.endDateStr);
        }

        return endDate;
    }
    public void setEndDate(Integer endDate) {
        this.endDate = endDate;
    }

    public String getCycleState() {
        return cycleState;
    }
    public void setCycleState(String cycleState) {
        this.cycleState = cycleState == null ? null : cycleState.trim();
    }

    public String getStartDateStr() {
        return startDateStr;
    }
    public void setStartDateStr(String startDateStr) {
        this.startDateStr = startDateStr == null ? null : startDateStr.trim();
    }

    public String getEndDateStr() {
        return endDateStr;
    }
    public void setEndDateStr(String endDateStr) {
        this.endDateStr = endDateStr == null ? null : endDateStr.trim();
    }

    public Integer getServerDate() { return serverDate; }
    public void setServerDate(Integer serverDate) { this.serverDate = serverDate; }
}